package demo1;

import static java.lang.Thread.sleep;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-07-23
 * Time: 22:12
 */



public class TestThread {

    //创建MyThread类 继承 Thread类
    public static class MyThread extends Thread {
        @Override
        //创建MyThread类继承Thread类 重写Thread的run方法
        public void run() {//这个run方法是为线程安排工作
           while(true){
               try {
                   System.out.println("hello ==> thread");
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }

           }
        }
    }

    public static void main(String[] args) {
        Thread t = new MyThread();//为线程创建实例
        t.start();//调用start方法-->创建线程(告诉线程可以开始工作了)// -->1.创建pcb 2.把pcb加入到双向链表中
        while(true){
            System.out.println("hello ====> main");
        }
    }

}
